﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using System;
using NJamb.Parser.SpecificationBuilders.Delta.Singular;
using NJamb.Parser.Subjects;
using Stile.Patterns.SelfDescribingPredicates;
#endregion

namespace NJamb.Specifications.Simple.Singular
{
    public class SingularSpecification<TSubject> :
        Specification<TSubject, ICollaboratingSubject<TSubject>, ISingularDeltaSpecificationBuilder<TSubject>>,
        ISingularSpecification<TSubject>
    {
        public SingularSpecification(ICollaboratingSubject<TSubject> subject,
            ISelfDescribingPredicate<TSubject> selfDescribingPredicate,
            Lazy<string> lazyReason = null,
            Func<Exception, TSubject, IEvaluation<TSubject>> exceptionFilter = null)
            : base(subject, selfDescribingPredicate, lazyReason, exceptionFilter) {}

        public ISingularSpecification<TSubject> Because(Lazy<string> lazyReason)
        {
            return new SingularSpecification<TSubject>(CollaboratingSubject, SelfDescribingPredicate, lazyReason);
        }

        protected override ISingularDeltaSpecificationBuilder<TSubject> Factory()
        {
            return new SingularDeltaSpecificationBuilder<TSubject>(this);
        }
    }
}
